package com.jack.base.desiginmodel.strategy;

/**
 * Created by zhang_j on 2019/12/17
 */
public class Context {
    private Strategy strategy;

    public void setStrategy(Strategy strategy){
        this.strategy = strategy;
    }

    public int executeStrategy(int a,int b){
        return strategy.doOperation(a,b);
    }

    public static void main(String[] args) {

        Context context = new Context();
        context.setStrategy(new MultiplyOperation());
        System.out.println(context.executeStrategy(10,5));

        context = new Context();
        context.setStrategy(new AddOperation());
        System.out.println(context.executeStrategy(10,5));

        context = new Context();
        context.setStrategy(new SubOperation());
        System.out.println(context.executeStrategy(10,5));
    }
}
